import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/generated/a.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/common/app_spaces.dart';
import 'package:finance_app/src/utils/cash_utils.dart';
import 'package:finance_app/src/widgets/common/tag_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';

class ReconcileTopListItem extends StatelessWidget {
  final String datetime;
  final String name;
  final String code;
  final String status;
  final num amount;
  final VoidCallback onTap;

  ReconcileTopListItem(
      {Key key,
      this.datetime,
      this.name,
      this.code,
      this.status,
      this.amount,
      this.onTap})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return PressedOpacityButton(
      onPressed: onTap,
      padding: EdgeInsets.symmetric(
        horizontal: getDp(25),
        vertical: getDp(15),
      ),
      child: Row(
        children: [
          SvgPicture.asset(
            A.assetsImagesStyleBank_4,
            width: getDp(24),
            height: getDp(24),
          ),
          AppSpaces.w28,
          Text(
            datetime,
            style: TextStyle(
              color: aceBlackColor,
              fontSize: getSp(16),
              fontWeight: FontWeight.w400,
              height: 22 / 16,
            ),
          ),
          AppSpaces.w10,
          Expanded(
            child: Text(
              '$name \n $code',
              style: TextStyle(
                color: aceBlackColor,
                fontSize: getSp(16),
                fontWeight: FontWeight.w400,
                height: 22 / 16,
              ),
              textAlign: TextAlign.start,
            ),
          ),
          Column(
            crossAxisAlignment: CrossAxisAlignment.end,
            children: [
              if (status != null)
                NormalRedTagWidget(
                  content: status,
                ),
              AppSpaces.h5,
              Text.rich(
                TextSpan(
                    text: CashUtils.operation(amount),
                    style: TextStyle(
                      fontSize: getSp(16),
                      color: CashUtils.getColor(amount),
                      fontWeight: FontWeight.bold,
                      height: 14 / 12,
                    ),
                    children: [
                      TextSpan(
                          text: '${CashUtils.ignoreFormatCashAmount(amount)}',
                          style: TextStyle(
                            color: aceBlackColor,
                            fontSize: getSp(16),
                            fontWeight: FontWeight.w400,
                            height: 14 / 16,
                          )),
                    ]),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
